package com.guodexian.controller;

import com.guodexian.entity.User;
import com.guodexian.service.UserService;
import com.guodexian.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 类说明：<br>
 *
 * @author PC-31 <br>
 * 2024/12/25 11:00<br>
 * @since 1.0 <br>
 * 黄淮学院计科2201B杨蕊 <br>
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/{id}")
    @ResponseBody
    public Result<User> login(@PathVariable int id) {
        User user=userService.selectUserById(id);
        Result<User> result=new Result<>();
        if(user!=null){
            result.setData(user);
            result.setMsg("success");
        }else {
            result.setMsg("fail");
            result.setCode(1);
        }
        return result;
    }
}